@extends('layouts.admin')

@section('content')
<section id="main-content">
    <section class="wrapper">
        <!-- page start-->
        <div class="row">
            <div class="col-lg-12">
                <section class="panel">
                  
                    
                    <header class="panel-heading">
                        用户列表
                    </header>
                    <div class="row">
                          <div class="panel-body right"  align="right">
                              
                             <form class="form-inline" action="{{ route('admin.member') }}" role="form" method="get">
                                  {{ csrf_field() }}
                                  <div class="form-group">
                                  @inject('rolePresenter','App\Presenters\RolePresenter')

                                    {!! $rolePresenter->rolesSelect() !!}
                                  </div>
                                  <div class="form-group">
                                      <!-- <label class="sr-only" for="exampleInputEmail2">Email address</label> -->
                                      <input type="text" class="form-control tooltips" id="name" data-toggle="tooltip" name="name"  @if(isset($_GET['name'])) value="{{ $_GET['name'] }}" @endif placeholder="输入用户名">
                                  </div>
                                  <div class="form-group">
                                      <!-- <label class="sr-only" for="exampleInputPassword2">Password</label> -->
                                      <input type="text" class="form-control" id="mobile" name="mobile" @if(isset($_GET['mobile'])) value="{{ $_GET['mobile'] }}" @endif placeholder="输入手机">
                                  </div>
                                  
                                  <button type="submit" class="btn btn-info">搜索</button>
                              </form>

                          </div>
                    </div>
                    <table class="table table-striped table-advance table-hover">
                        <thead>
                        <tr>
                             <th>
                                  <span class="ckbox ckbox-primary">
                                      <!-- <input type="checkbox" id="selectall"/> -->
                                      <label for="selectall"></label>
                                  </span>
                              </th>
                              <th>用户名</th>
                              <th>手机</th>
                              <th>上级</th>
                              <th>余额</th>
                              <th>冻结</th>
                              <!-- <th>所属角色</th> -->
                              <th>创建时间</th>
                              <th>操作</th>
                            <!-- <th><i class="icon-bullhorn"></i> Company</th>
                            <th class="hidden-phone"><i class="icon-question-sign"></i> Descrition</th>
                            <th><i class="icon-bookmark"></i> Profit</th>
                            <th><i class=" icon-edit"></i> Status</th>
                            <th></th> -->
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                        @foreach($users as $user)
                              <tr>
                                  <td>
                                      <div class="ckbox ckbox-default">
                                          <!-- <input type="checkbox" name="id" id="id-{{ $user->id }}"
                                                 value="{{ $user->id }}" class="selectall-item"/> -->
                                          <label for="id-{{ $user->id }}"></label>
                                      </div>
                                  </td>
                                  <td>{{ $user->name }}</td>
                                  <td>{{ $user->mobile }}</td>
                                  <td>
                                    @inject('userPresenter','App\Presenters\UserPresenter')

                                    {!! $userPresenter->parent($user->parent_id) !!}
                                    </td>
                                  <td>{{ $user->balance }}</td>
                                  <td>{{ $user->frozen_funds }}</td>
                                  <!-- <td>
                                      @if($user->roles()->count())
                                          @foreach($user->roles()->get() as $role)
                                              <span class="label label-primary">{{ $role->name }}</span>
                                          @endforeach
                                      @else
                                          <span class="label label-default">无</span>
                                      @endif
                                  </td> -->
                                  <td>{{ $user->created_at }}</td>
                                  <td>
                                      <a href="{{ route('admin.member.edit',['id'=>$user->id]) }}"
                                         class="btn btn-primary btn-xs"><i class="icon-pencil"></i> </a>
                                      <a class="btn btn-success btn-xs"
                                         href="{{ route('admin.member.subs',['id'=>$user->id]) }}">
                                          <i class="icon-user-md"></i> </a>
                                      <a href="{{ route('admin.member.balance',['id'=>$user->id]) }}"
                                            class="btn btn-danger btn-xs role-permissions"><i class="icon-money"></i> </a>
                                      
                                  </td>
                              </tr>
                          @endforeach
                        </tr>
                       <!--  <tr>
                            <td><a href="#">Vector Ltd</a></td>
                            <td class="hidden-phone">Lorem Ipsum dorolo imit</td>
                            <td>12120.00$ </td>
                            <td><span class="label label-info label-mini">Due</span></td>
                            <td>
                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                            </td>
                        </tr> -->
                  
                        </tbody>
                    </table>
                     {!! $users->render() !!}
                     </div>
                    </div>
                </section>
            </div>
        </div>
        <!-- page end-->
    </section>
</section>
@endsection
@section('javascript')
  
    <!-- <script src="{{ asset('backend/rbacjs/modernizr.min.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/toggles.min.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/retina.min.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/jquery.cookies.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/flot/flot.min.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/flot/flot.resize.min.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/morris.min.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/raphael-2.1.0.min.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/chosen.jquery.min.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/sweetalert.min.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/custom.js') }}"></script>
    <script src="{{ asset('backend/rbacjs/ajax.js') }}"></script> -->
    <script type="text/javascript">
        $(".user-delete").click(function () {
            Rbac.ajax.delete({
                type:'delete',
                data:{"_token" : "{{ csrf_token() }}" },
                confirmTitle: '确定删除用户?',
                href: $(this).data('href'),
                successTitle: '用户删除成功',
                errorFnc:function(data){
                      swal('删除失败！', '', 'error');
                }
            });
        });

        $(".deleteall").click(function () {
            Rbac.ajax.deleteAll({
                confirmTitle: '确定删除选中的用户?',
                href: $(this).data('href'),
                successTitle: '用户删除成功'
            });
        });
    </script>

@endsection

